function returnObj(){
	var result;
	var msg;
}

/**
 * 判断有没有插入管理员密钥盘
 */ 
function isAdminKey(){
	var SMObj = document.getElementById("SMObj");
	var isCreate = false;
	
	try{
		isCreate = SMObj.WebCreateKeyObject();
		SMObj.WebOpenKeyObject();
		var nKeyCount = SMObj.WebGetKeyCount();
		for(var i=0; i<nKeyCount; i++){
			SMObj.WebConnectKey(i);
			if(SMObj.WebKeyIsAdmin()){
				return true;
			}
		}
	} catch(e){
		alert("客户端异常：" + e.message);
		return false;
	} finally {
		if(isCreate){
			SMObj.WebDeleteKeyObject();
		}
	}
	alert("请插入管理员密钥盘！");
	return false;
}

/**
 * 判断是否两个密钥盘,一个是管理员密钥盘，一个用户密钥盘
 */
function isAdminAndUser(){
	var SMObj = document.getElementById("SMObj");
	var obj = new returnObj();
	var isCreate = false;
	var nKeyCount = 0;
	var adminCount = 0;
	var userCount = 0;
	
	try{
		isCreate = SMObj.WebCreateKeyObject();
		SMObj.WebOpenKeyObject();
		nKeyCount = SMObj.WebGetKeyCount();
		for(var i=0; i<nKeyCount; i++){
			SMObj.WebConnectKey(i);
			if(SMObj.WebKeyIsAdmin()){
				adminCount++;
			} else {
				userCount++;
				obj.msg = SMObj.WebGetKeySerialNumber();
				obj.result = true;
			}
		}
	} catch(e){
		obj.msg = "客户端异常：" + e.message;
		obj.result = false;
	} finally {
		if(isCreate){
			SMObj.WebDeleteKeyObject();
		}
	}
	
	if(nKeyCount == 0){
		obj.msg = "请插入管理员密钥盘和用户密钥盘！";
		obj.result = false;
	}
	
	if(adminCount == 0){
		obj.msg = "请插入管理员密钥盘！";
		obj.result = false;
	}
	
	if(adminCount > 1){
		obj.msg = "只能插入一个管理员密钥盘！";
		obj.result = false;
	}
	
	if(userCount == 0){
		obj.msg = "请插入用户密钥盘！";
		obj.result = false;
	}
	
	if(userCount > 1){
		obj.msg = "只能插入一个用户密钥盘！";
		obj.result = false;
	}
	return obj;
}